package com.lijin.batchsys.framework.control;

import com.lijin.batchsys.framework.dao.model.JobInfo;
import com.lijin.batchsys.framework.dao.model.StepInfo;

public class BatchSysJobFactory {

	/**
	 * 根据Job配置信息构造Job
	 * 
	 * @param jobInfo
	 * @param batchDateStr
	 * @return
	 */
	public static IBatchSysJob buildBatchSysJob(JobInfo jobInfo) {
		IBatchSysJob job = null;
		// 如果任务配置为步骤可并行执行，则返回BatchSysConcurrentJob实例，否则返回BatchSysFlowJob实例
		if (jobInfo.isConcurrent()) {
			job = new BatchSysConcurrentJob(jobInfo);
		} else {
			job = new BatchSysFlowJob(jobInfo);
		}
		for (StepInfo stepInfo : jobInfo.getStepList()) {
			BatchSysStep step = new BatchSysStep(stepInfo);
			job.addStep(step);
		}
		return job;
	}

}
